// pages/physical-success/physical-success.js
Page({
	data: {
		patientName: '',
		packageName: '',
		packagePrice: '',
		appointmentDate: ''
	},

	onLoad(options) {
		console.log('体检预约成功页面加载')
		console.log('页面参数:', options)
		
		if (options.patient) {
			this.setData({
				patientName: options.patient
			})
		}
		
		if (options.package) {
			try {
				const packageData = JSON.parse(options.package)
				this.setData({
					packageName: packageData.name,
					packagePrice: packageData.price
				})
			} catch (e) {
				console.error('解析套餐数据失败:', e)
			}
		}
		
		if (options.date) {
			this.setData({
				appointmentDate: options.date
			})
		}
	},

	// 查看预约详情
	viewDetail() {
		console.log('查看预约详情')
		wx.navigateTo({
			url: '/pages/physical-detail/physical-detail?patient=' + this.data.patientName + 
				 '&package=' + JSON.stringify({
					 name: this.data.packageName,
					 price: this.data.packagePrice
				 }) + 
				 '&date=' + this.data.appointmentDate
		})
	},

	// 返回首页
	goHome() {
		console.log('返回首页')
		wx.reLaunch({
			url: '/pages/index/index'
		})
	}
})
